import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
import { ExplorerInfo } from "../model/ExplorerInfo";
import { StringHelper } from "../../../com/gengine/utils/StringHelper";
type int = number;
//class ExplorerConfig
    
    export  class ExplorerConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._infoArr = new Array<any>();
            if (ExplorerConfig._instance != null) 
            {
                throw new Error("ExplorerConfig 单例");
            }
            this.init();
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_explorer_config.json");
            this.write(loc1);
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1;
            for(loc2 of loc4) 
            {
                loc1 = new ExplorerInfo();
                loc1.amount = loc2.amount;
                loc1.cost = loc2.cost;
                loc1.name = StringHelper.getString(loc2.name);
                loc1.type = loc2.type;
                loc1.prop = loc2.prop;
                loc1.unit = loc2.unit;
                loc1.systemUpper = loc2.systemUpper;
                loc1.systemLower = loc2.systemLower;
                loc1.personUpper = loc2.personUpper;
                loc1.personLower = loc2.personLower;
                loc1.isActive = loc2.isActive;
                loc1.activeRank = loc2.activeRank;
                loc1.messageKey = loc2.messageKey;
                loc1.activeKey = loc2.activeKey;
                loc1.minLevel = loc2.minLevel;
                loc1.maxLevel = loc2.maxLevel;
                this._map[loc1.type + "_" + loc1.cost] = loc1;
                this._infoArr.push(loc1);
            }
            return;
        }

        public getExplorerInfoByType(arg1: int): Array<any>
        {
            var loc2=null;
            var loc1=[];
            var loc3=0;
            var loc4=this._infoArr;
            for(loc2 of loc4) 
            {
                if (loc2.type != arg1) 
                {
                    continue;
                }
                loc1.push(loc2);
            }
            return loc1;
        }

        public getExplorerInfoByActiveWorldLevel(arg1: int): ExplorerInfo
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._infoArr;
            for(loc1 of loc3) 
            {
                if (!(loc1.isActive == 1 && arg1 >= loc1.minLevel && arg1 <= loc1.maxLevel)) 
                {
                    continue;
                }
                return loc1;
            }
            return null;
        }

        public static get instance(): ExplorerConfig
        {
            if (ExplorerConfig._instance == null) 
            {
                ExplorerConfig._instance = new ExplorerConfig();
            }
            return ExplorerConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_infoArr: Array<any>;

        /* internal */ static /* var */_instance: ExplorerConfig;
    }
